package com.zhouheng.springbootjpa.entity;

import lombok.Data;
import org.springframework.data.mongodb.core.mapping.Document;

import javax.persistence.Id;
import java.util.List;

/**
 * 模式资料格点数据存储类，
 * 格点存储方式为:从0,0点起始，先纬度从0-90度递增，然后经度从0-180度递增
 *
 * @author LeoRmAo
 * @date 20181212 15:45:07
 * @since v1.0
 */
@Data
@Document
public class GridInfo {

    @Id
    private String id;

    private String dataType;

    private String elementType;

    private Integer observeYear;

    private String observeMonthDay;

    private Integer forecastIndex;

    private List<GridData> gridDataList;

    /**
     * 根据经纬度获取索引值
     *
     * @param lon 描述此参数
     * @param lat 描述此参数
     * @return 返回 integer 描述此返回参数
     * @author LeoRmAo
     * @date 20181212 17:28:52
     * @since v1.0
     */
    public static Integer calculateIndex(Double lon, Double lat) {
        return (int)(lon / 2.5 * 37 + lat / 2.5);
    }

}
